package com.sangu.dianxiu.ui;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.sangu.dianxiu.R;

public class AdvDetailActivity extends BaseActivity {

    @ViewInject(R.id.wv_activity_adv_content)                           //使用xutils的注解功能，这样就不用findviewbyid了
    private WebView webView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_adv_detail);
        ViewUtils.inject(this);                                             //如果没有此行，则上面的注解不会生效
        final String advUrl=getIntent().getStringExtra("advUrl");           //从点击广告的界面获得传过来的广告的URL
        webView.getSettings().setJavaScriptEnabled(true);                   //设置支持JavaScript
        webView.loadUrl(advUrl);
        webView.setWebViewClient(new WebViewClient(){                       //设置不调用系统浏览器打开相应的网页，而是在webview中打开
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                webView.loadUrl(url);
                return true;
            }
        });
    }

}

